package cn.zz.comm.types.result;

import java.util.List;

import cn.zz.comm.core.types.query.PageQuery;
import lombok.Getter;
import lombok.Setter;

/**
 * @author zhongq
 * @since 2022/3/19
 */
@Getter
@Setter
public class P<T> {
	private List<T> records;
	private long total;
	private long size;
	private long current;

	public P(List<T> records, long total, long size, long current) {
		this.records = records;
		this.total = total;
		this.size = size;
		this.current = current;
	}

	public P(PageQuery pageQuery, List<T> records) {
		this.records = records;
		this.total = pageQuery.getTotal();
		this.size = pageQuery.getSize();
	}

	public static <T> P<T> of(PageQuery page, List<T> data) {
		return new P<>(page, data);
	}

}